/**
 * 
 */
package simulation;

import java.util.ArrayList;

import common.Stat;

/**
 * @author vladimir
 * 
 */
public class CorrTime_clock {
	int Correlation_Length = 0;
	int[][] neighbors;
	int L = -1;
	double J = 0;
    int q = -1;
	double T = -1;
	public LatticeClock Lat;
	int mcs = 40000;

	public CorrTime_clock(int[][] neighbors, double J, int L, int q, double T) {
		this.neighbors = neighbors;
		this.L = L;
		this.J = J;
		this.q = q;
		this.T = T;
		ArrayList<Double> M = Simlation();
		this.Correlation_Length = Stat.corLen(M);
		if (this.Correlation_Length > 300) {
			this.Correlation_Length = 300;
		}
	}

	// here we do simulation and return Magnetization square value
	private ArrayList<Double> Simlation() {
		int ThermalMCS = 20000;
		this.Lat = new LatticeClock(this.neighbors, this.J, this.L, this.q, this.T);
		ArrayList<Double> tM = new ArrayList<Double>();
		// start loop for sweeps
		for (int sweep = 0; sweep <= this.mcs; sweep++) {
			// update lattice
			Lat.update();
			if (sweep > ThermalMCS) {
				// record data at each appropriate sweep
				//tM.add(Lat.M_total());
                tM.add(Lat.Energy());
			}
		}
		return tM;
	}

	public int SweepStep() {
		return this.Correlation_Length;
	}

	public int MCS() {
		return 100000 * this.Correlation_Length;
	}

	public int ThermalMCS() {
		return 5000 * this.Correlation_Length;
	}

}
